nvmet-tcp: Fix a possible UAF in queue intialization setup
authorSagi Grimberg <sagi@grimberg.me>
Mon, 2 Oct 2023 10:54:28 +0000 (13:54 +0300)
committerSalvatore Bonaccorso <carnil@debian.org>
Sun, 22 Oct 2023 19:28:21 +0000 (21:28 +0200)
commitc2dc6c7b323f620324cfbc1a03e6d7d1c2996c5a
treedfb034f66074e62bb31f5500103c1fbdf1342ad1
parent3dccb97e599648d30c9eb793b49d517d16268afc
nvmet-tcp: Fix a possible UAF in queue intialization setup

Origin: https://git.kernel.org/linus/d920abd1e7c4884f9ecd0749d1921b7ab19ddfbd
Bug-Debian-Security: https://security-tracker.debian.org/tracker/CVE-2023-5178

From Alon:
"Due to a logical bug in the NVMe-oF/TCP subsystem in the Linux kernel,
a malicious user can cause a UAF and a double free, which may lead to
RCE (may also lead to an LPE in case the attacker already has local
privileges)."

Hence, when a queue initialization fails after the ahash requests are
allocated, it is guaranteed that the queue removal async work will be
called, hence leave the deallocation to the queue removal.

Also, be extra careful not to continue processing the socket, so set
queue rcv_state to NVMET_TCP_RECV_ERR upon a socket error.

Cc: stable@vger.kernel.org
Reported-by: Alon Zahavi <zahavi.alon@gmail.com>
Tested-by: Alon Zahavi <zahavi.alon@gmail.com>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Gbp-Pq: Topic bugfix/all
Gbp-Pq: Name nvmet-tcp-Fix-a-possible-UAF-in-queue-intialization-.patch
drivers/nvme/target/tcp.c